package com.only4play.common.mapper;

import java.time.Instant;
import java.util.Objects;

/**
 * DateMapper
 *
 * @author liyuncong
 * @date 2023/11/06 10:30
 **/
public class DateMapper {
    public Long asLong(Instant date) {
        if (Objects.nonNull(date)) {
            return date.toEpochMilli();
        }
        return null;
    }

    public Instant asInstant(Long date) {
        if (Objects.nonNull(date)) {
            return Instant.ofEpochMilli(date);
        }
        return null;
    }
}
